<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>修改密码</title>
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0" />
    <link rel="stylesheet" href="./css/index.css"/>
    <script src="./js/jquery.js"></script>
    <script src="lib/layer/layer.js"></script>
    <script src="js/base.js"></script>
    <script src="lib/vue/vue.min.js"></script>
    <script src="lib/vue/vue-resource.min.js"></script>
    <link rel="stylesheet" href="./css/iconfont1.css"/>
</head>
<script type="text/javascript">
    (function () {
        var deviceWidth = document.documentElement.clientWidth;
        if (deviceWidth > 640) deviceWidth = 640;
        document.documentElement.style.fontSize = deviceWidth / 6.4 + 'px';
    }());
</script>
<body>
<div class="perCenter" id="app">
    <div class="per_left">
        <p><span class="bottom_color">首页</span> > <span>个人中心</span></p>
        <div class="data">
            <div class="photo">
                <img :src="info.real_avatar" alt=""/>
                <p>{{info.name}}</p>
            </div>
            <ul class="name">
                <a href="./task_center.html"><li ><i class="icon iconfont icon-zhengjianhao-copy"></i>任务中心</li></a>
                <a href="./myVirtual.html"><li ><i class="icon iconfont icon-zhuji2"></i>我的虚拟机</li></a>
                <a href="./personalData.html"><li ><i class="icon iconfont icon-gerenziliao"></i>个人资料</li></a>
                <a href="./invitedShare.html"><li > <i class="icon iconfont">&#xe690;</i>邀请分享</li></a>
                <a href="./password.html"><li class="person"> <i class="icon iconfont icon-xiugaimima"></i>修改密码</li></a>
            </ul>
        </div>
    </div>
    <div class="task" style="margin-top: 50px;">
        <p class="perTitle" style="border: none;"><i></i><span>修改密码</span></p>
        <div class="change">
            <div>
                <span>*</span><label>原始密码:</label><input v-model="origin_password" type="text"/>
            </div>
            <div>
                <span>*</span><label>新 密 码 :</label><input v-model="password" type="text"/>
            </div>
            <div>
                <span>*</span><label>确认密码:</label><input v-model="password_confirmation" type="text"/>
            </div>
            <div class="btn"><button @click="submit()">确 认</button></div>
        </div>
    </div>
</div>
<div class="footer"></div>
</body>
<script>
    (function () {
        var app = new Vue({
            el: '#app',
            data: function () {
                return{
                    origin_password: "",
                    password_confirmation:"",
                    password:"",
                    info:[]
                }
            },
            mounted: function () {
                this.showData();
//需要执行的方法可以在mounted中进行触发，其获取的数据可以赋到data中后，可以放在前面进行渲染
            },
            methods: {
                showData:function(){
                    var _this = this;
                    get(url + 'user/info', {}).then(
                            function (res) {
                                if (res.body.code == 101) {
                                    tip(res.body.msg);
                                    location.href = './login.html'
                                } else if (res.body.code == 400) {
                                    tip(res.body.msg);
                                } else {
                                    _this.info = res.body.data
                                }
                            }, function (reason) {
                                tip('请求错误')
                            });
                },
                submit: function () {
                    var _this = this;
                    console.log(this.origin_password)
                    if(this.password_confirmation == this.password){
                        post(url + 'user/modify-pass',{origin_password:this.origin_password,password:this.password,password_confirmation:this.password_confirmation}).then(
                                function (res) {
                                    if (res.body.code == 101) {
                                        tip(res.body.msg);
                                        location.href = './login.html'
                                    } else if (res.body.code == 400) {
                                        tip(res.body.msg);
                                    } else {
                                        tip(res.body.msg);
                                    }
                                }, function (reason) {
                                    tip('请求错误')
                                });
                    }else{
                        tip('请对照两次输入的密码不一致')
                    }

                }
            }
        })
    })()
    $('.footer').load("./footer.html")
</script>
</html>